const Pv = require('../model/pv');
/**
 * 文章中间件
 */
module.exports = {
    /**
     *  获取总访问量
     */
    getTotal:(req,res,next) =>{
        Pv.getTotal().then(results =>{
            req.hitsCount = results;
            next();
        }).catch(err=>{
            next(err);
        });
    },

    /**
     *  获取全部访问量信息
     */
    getCateNum:(req,res,next) =>{
        Pv.getCateNum().then(results =>{
            req.cateCount = results;
            next();
        }).catch(err=>{
            next(err);
        });
    },
    /**
     *  获取总类目数
     */
    getAll:(req,res,next) =>{
        Pv.getAll().then(results =>{
            req.pvs = results;
            next();
        }).catch(err=>{
            next(err);
        });
    },
}